package com.beiding.my.common.query;

import com.beiding.my.common.Bo;
import com.beiding.my.common.QuoteExpressionRegistry;

public abstract class InnerExpression extends Expression {
    Expression font;

    public InnerExpression(Expression font) {
        this.font = font;
    }

    @Override
    protected String createExpression(QuoteExpressionRegistry registry, Class<? extends Bo> type, ParamHolderCreator paramHolderCreator, CreateResult createResult) {
        return font.createExpression(registry, type, paramHolderCreator, createResult) + " " + createExpressionLocal(registry, type, paramHolderCreator, createResult);
    }

    protected abstract String createExpressionLocal(QuoteExpressionRegistry registry, Class<? extends Bo> type, ParamHolderCreator paramHolderCreator, CreateResult createResult);

    public InnerConnectorHasBody and(Expression... conditionExpressions) {
        InnerConnectorHasBody r = new InnerConnectorHasBody(this);
        r.setBody(conditionExpressions);
        r.setSymbol("and");
        return r;
    }

    public InnerConnectorHasBody or(Expression... conditionExpressions) {
        InnerConnectorHasBody r = new InnerConnectorHasBody(this);
        r.setBody(conditionExpressions);
        r.setSymbol("or");
        return r;
    }


}
